#include <stdio.h>
#include <string.h>

#define STDIN
//#define DEBUG

int last[10001];
int main()
{
#ifdef STDIN
    freopen("bin/1604.in", "r", stdin);
#endif
    int i, N;

    memset(last, 0, sizeof(last));
    last[0] = 1;


    int n5 = 0;

    while(scanf("%d", &N) != EOF)
    {
        n5 = 0;
        int k = 5;
        while(N / k > 0)
        {
            n5 += N/k;
            k *= 5;
        }
#ifdef DEBUG
        printf("N: %d n5: %d\n", N, n5);
#endif
        for (i = 1, last[0] = 1; i <= N; i++)
        {
            last[i] = i;
        }

        //同时消去5和2
        int step2 = 2, step5 = 5;
        int begin2 = 2, begin5 = 5;
        int i2, i5;
        while(begin5 <= N)
        {
            for (i5 = begin5, i2 = begin2; i5 <= N;)
            {
                last[i5] /= 5;

                last[i2] /= 2;

                i2 += step2;
                i5 += step5;
            }

            begin5 *=  5;
            begin2 *= 2;
            step5 *= 5;
            step2 *= 2;

#ifdef DEBUG
            for (i = 0; i <= N; ++i)
                printf("%d ", last[i]);
            printf("\n");
#endif
        }

        int digit = 1;
        for (i = 0; i <= N; i++)
        {
            digit = (digit * last[i]) % 10;
        }
        printf("% 5d -> %d\n", N, digit);


    }
    return 0;
}
